home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
BORL_TIP
/
TI100
/
TI310.ASC
< prev
next >
Wrap
Text File
|
1991-09-11
|
2KB
|
133 lines
PRODUCT : TURBO PASCAL NUMBER : 310
VERSION : 3.0xx
OS : PC-DOS, MS-DOS
DATE : June 19, 1986 PAGE : 1/2
TITLE : FILE ATTRIBUTES, SETTING & GETTING
Use the following routines to set and get a particular file's
attribute from within a Turbo Pascal program.
type
AnyString = string[80]; { Generic string type }
Registers = record
case Byte of
1 : (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags: integer);
2 : (AL, AH, BL, BH, CL, CH, DL, DH: byte);
end;
function SetFileAttribute(FileName : AnyString;
Attribute : integer) : integer;
{ Sets a particular file's attribute byte - returns error code:
0 - no error
2 - file not found
3 - path not found
5 - access denied
}
var Reg : Registers;
begin
Reg.AH := $43;
Reg.AL := $01;
Reg.CX := Attribute;
FileName := FileName + #0;
{ Make the file name an ASCIIZ string }
Reg.DS := Seg(FileName);
Reg.DX := Succ(Ofs(FileName));
{ The offset of the first char in the name }
MsDos(Reg);
if not (Reg.AX in [2, 3, 5]) then
Reg.AX := 0;
SetFileAttribute := Reg.AX;
end; { SetFileAttribute }
function GetFileAttribute(FileName : AnyString;
var Attribute : integer) : integer;
{ Gets a particular file's attribute byte - returns error code:
0 - no error
2 - file not found
PRODUCT : TURBO PASCAL NUMBER : 310
VERSION : 3.0xx
OS : PC-DOS, MS-DOS
DATE : June 19, 1986 PAGE : 2/2
TITLE : FILE ATTRIBUTES, SETTING & GETTING
3 - path not found
5 - access denied
}
var Reg : Registers;
begin
Reg.AH := $43;
Reg.AL := $00;
FileName := FileName + #0;
{ Make the file name an ASCIIZ string }
Reg.DS := Seg(FileName);
Reg.DX := Succ(Ofs(FileName));
{ The offset of the first char in the name }
MsDos(Reg);
Attribute := Reg.CX;
if not (Reg.AX in [2, 3, 5]) then
Reg.AX := 0;
GetFileAttribute := Reg.AX;
end; { GetFileAttribute }